<?php

namespace App\Policies;

use App\Models\User;
use App\Models\PrizeRecord;

class PrizeRecordPolicy extends Policy
{
    public function update(User $user, PrizeRecord $prize_record)
    {
        $company=$prize_record->prize->product->company;
        if (($user->can('manage_products')) && ($user->companies->contains($company))){
            return true;
        }

        return $user->isOwnerOf($prize_record);

    }

    public function destroy(User $user, PrizeRecord $prize_record)
    {
        return false;
    }
}
